<html ng-app="diandanbao" class="ng-scope">
<head>
    <style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\:form{display:block;}</style>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="telephone=no" name="format-detection">
    <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
    <title>预订订单</title>
    <link data-turbolinks-track="true" href="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/weixin.css" media="all" rel="stylesheet">
    <style type="text/css">@media screen{.smnoscreen {display:none}} @media print{.smnoprint{display:none}}</style>
    <script src="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/common.min.js"></script>
    <script src="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/gg.min.js"></script> 
    <link rel="stylesheet" href="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/common.min.css">
    <link rel="stylesheet" href="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/page-6c7ae247c5.min.css">
</head>
<body>
<div ng-view="" style="height: 100%;" class="ng-scope">
    <div class="ddb-nav-header ng-scope" common-header="">
        <div class="nav-left-item" onclick="location.href='{php echo $this->createMobileUrl('detail', array('id' => $storeid, 'mode' => 3), true)}';"><i class="fa fa-angle-left"></i></div>
        <div class="header-title ng-binding">预订停车位</div>
    </div>
    <div id='CPH'>
        <div class="section ng-scope" style=" margin-top: 40px;margin-bottom: 0px;">
            <div class="list-item  ddb-form-control custom-form-element ng-scope">
                <div class="ddb-form-label ng-binding">车牌号</div>
                <input class="carnum" style="height: 30px;">
            </div>
        </div>
    </div>
    
    <div class="main-view ng-scope" id="time-points-index" style="padding-top: 1px;">
        <!--<div class="notification-section">-->
            <!--<div class="notice">-->
                <!--<i class="fa fa-volume-up red"></i>-->
                <!--<marquee behavior="alternate" scrollamount="1" scrolldelay="1">&nbsp;20分钟未到店，商家有权取消本次预订，请安排好您的时间&nbsp;</marquee>-->
            <!--</div>-->
        <!--</div>-->
        </div>
      
        <div class="ng-scope">
            <header>
                <section class="top-menu">
                    <span  style="margin-left: 10px;"><img src="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/222.png" alt=""></span>
                    <div id="J_top_menu" class="top-menu-list">
                           {loop $parkzones $item}
                            <a src="0" rel="{$item['id']}" alt="{$item['title']}">{$item['title']}</a>
                            {/loop}
                    </div>
                    <span style="margin-right: 10px;" class='span_2'><img style="width: 22px;margin-top: -2px;" src="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/111.png" alt=""></span>
                </section>
            </header>
        </div>
        <div class='h31'>
                <div class='h41'><!--车位图-->
                     <div class="img_WZ"> <!--座位图-->
                    </div>
                    <div class='WZ_Z'>
                        <ul  class="WZ_Z_1"><!--车位列表-->
                            
                        </ul>
                    </div>
                </div>
        </div>
        <div class="addinput">
           <input class="park_zuotypeid" type="hidden" name="zuotypeid" value="{$zuotypeid}"/>
           <input class="park_carnums" type="hidden" name="carnum" value=""/>
           <input class="park_parkv" type="hidden" name="park" value=""/>
           <input class="park_selectdate" type="hidden" name="selectdate" value="{$selectdate}"/>
           <input class="park_selecttime" type="hidden" name="selecttime" value="{$selecttime}"/>
           <input class="park_tableid" type="hidden" name="tableid" value="{$tableid}"/>
        </div>
      <div class='button_1'>
            <!--  <span id='button_1_span'>+ 新增 车牌号</span>
             -->
            <span id='button_1_span'>+ 新增 车牌号</span>
             <a class="next" style="padding-left: 30px;">下一步</a>
         </div> 
    </div>

<style type="text/css"> 
.selected{color: #DD551A !important;} 
</style>
 
<script>    
$(document).ready(function(){
     $($(".top-menu-list").children("a")[0]).removeClass('selected').trigger('click');
    $("#button_1_span").click(function(){
       var div= "<div class=\"section ng-scope\" style=\" margin-top: 0px;margin-bottom: 0px;\"><div class=\"list-item  ddb-form-control custom-form-element ng-scope\"><div class=\"ddb-form-label ng-binding\">车牌号</div><input class=\"carnum\" style=\"height: 30px;\">"+
              "</div></div>";
　  　$("#CPH").append(div);　　
    })
    
    /*
    $("#deleteTable").click(function(){
        var check = document.getElementsByName("check");
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                 document.getElementById('CPH').deleteRow(i);
                 i--;
            }
        }
    })*/
}) 
   
            
//            var typeid =$(this).attr('rel');
//        getdata(typeid);
//        $('.top-menu-list a').eq(0).attr("src","1");
//        $(".top-menu-list a").click(function() {
//                $('.top-menu-list a').eq(0).show().siblings().hide();
//            })
        $("#J_top_menu a").click(function() { 
           
             $(this).siblings('a').removeClass('selected'); 
             $(this).addClass('selected');  
             var typeid =$(this).attr('rel');
             getdata(typeid);
             var parktype = $(".top-menu-list").children("a");
             for(var i=0;i<parktype.length;i++){
                 $(parktype[i]).attr("src","0");
             }
             $(this).attr("src","1");
        })
        $(".next").click(function() {
                setcarnums();
                var parktypeid = 0;
                var carnums = $(".park_carnums").val();//车牌号，逗号分隔
                var park = $(".park_parkv").val();//停车位，逗号分隔
                var selectdate = $(".park_selectdate").val();//日期
                var selecttime = $(".park_selecttime").val();//时间
                var tableid = $(".park_tableid").val();//座位号
                var zuotypeid = $(".park_zuotypeid").val();//座位类型id
                var parktype = $(".top-menu-list").children("a");
                for(var i=0;i<parktype.length;i++){
                    if($(parktype[i]).attr("src")==1){
                        parktypeid = $(parktype[i]).attr("alt");
                    }
                }
                var url = "{php echo $this->createMobileUrl('ReservationDetail', array('storeid' => $storeid), true)}" + "&selectdate=" + selectdate + "&selecttime=" + selecttime+ "&tableid=" + tableid+ "&park=" + park+ "&carnums=" + carnums+ "&parktypeid=" + parktypeid+ "&zuotypeid=" + zuotypeid;
                window.location.href = url;
        })
        
       
    

//    function changeDate(obj) {
//        var date = obj.value;
//        var url = "{php echo $this->createMobileUrl('ReservationIndex', array('storeid' => $storeid), true)}" + "&selectdate=" + date;
//        window.location.href = url;
//    }
//
//    function selectTime(id) {
//
//        var select_date = $("#select_date").val();
//        var url = "{php echo $this->createMobileUrl('ReservationDetail', array('storeid' => $storeid), true)}" + "&selectdate=" + select_date + "&timeid=" + id;
//        window.location.href = url;
//    } 
    /**选车位逻辑***/
    function selectpark(obj){
        var selectedzuo;
        $(obj).attr("src","1");
        $(obj).find(".table_status").addClass('b4b4b4');
        var zuo = $(".WZ_Z_1").children("li");
        for(var i = 0;i<zuo.length;++i){
            if($(zuo[i]).attr("src")==1){
                if($.trim(selectedzuo)==''){
                    selectedzuo=$(zuo[i]).attr("alt");
                }else{
                    selectedzuo=selectedzuo+","+$(zuo[i]).attr("alt");
                }
                
            }
        }
        $(".park_parkv").val(selectedzuo);
    }
     function setcarnums(){
            var carnumarray = $(".list-item").find(".carnum");
            var carnums = "";
            for(var i=0;i<carnumarray.length;++i){
                if($.trim(carnums)==''){
                    carnums = $(carnumarray[i]).val();
                }else{
                    carnums = carnums +","+$(carnumarray[i]).val();
                }
            }
            $(".park_carnums").val(carnums);
        }
        
         /**
            function nextsumit(){
                var carnums = $(".park_carnums").val();
                var park = $(".park_parkv").val();
                var selectdate = $(".park_selectdate").val();
                var selecttime = $(".park_selecttime").val();
                var tableid = $(".park_tableid").val();
                var url = "{php echo $this->createMobileUrl('ReservationDetail', array('storeid' => $storeid ), true)}";
                $.ajax({
                        url: url, type: "post", dataType: "json", timeout: "10000",
                        data: {
                            "carnums": carnums,//车牌号，逗号分隔
                            "park": park,//停车位，逗号分隔
                            "selectdate": selectdate,//日期
                            "selecttime": selecttime,//时间
                            "tableid": tableid,//座位号
                        },
                        success: function (data) {
                            if (data.message['code'] != 0) {
//                                var url = "{php echo $this->createMobileUrl('pay', array(), true)}"+"&orderid="+data.message['orderid'];
//                                location.href = url;
                                   alert("success");
                            } else {
                                alert(data.message['msg']);
                                //'网络不稳定，请重新尝试!'
                            }
                        },error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest.status);
                            alert(XMLHttpRequest.readyState);
                            alert(textStatus);
                            alert("数据提交失败！");
                        }
                });
            }   ***/             
    function getdata(typeid){
                    setcarnums();
                    var htmlinsert="";
                    var imginsert="";
                   
                    var url = "{php echo $this->createMobileUrl('Getdatapark', array('storeid' => $storeid ), true)}";
                    $.ajax({
                        url: url, type: "post", dataType: "json", timeout: "10000",
                        data: {
                            "typeid": typeid,
                        },
                        success: function (data) {
                            if(data.message['code']!=0){
                                for(var i = 0;i<data.message['listbytpyid'].length;i++){
                                    var id = data.message['listbytpyid'][i]['id'];
                                    var status = data.message['listbytpyid'][i]['status'];
                                    var title = data.message['listbytpyid'][i]['title'];
                                    var user_count = data.message['listbytpyid'][i]['user_count'];
                                    if(status==0){
                                        status = "空闲";
                                    }else if(status==1){
                                        status = "开台";
                                    }else if(status==2){
                                        status = "已下单";
                                    }else if(status==3){
                                        status = "已支付";
                                    }
                                   htmlinsert=htmlinsert+'<li src="0" alt="'+title+'" rel="'+id+'" onclick="selectpark(this);"> <ul> <li class="table_status">'+status+'</li><li>'+title+'</li><li>'+"("+user_count+"人位)"+'</li></ul></li>';
                                }
                                $(".WZ_Z_1").html(htmlinsert);
                            }else{
                                alert("网络不稳定，请重新尝试!");
                            }
                        },error: function () {
                           alert("数据提交失败！");
                       }
                  });
                  var url_type = "{php echo $this->createMobileUrl('Gettypepark', array('storeid' => $storeid ), true)}";
                  $.ajax({
                        url: url_type, type: "post", dataType: "json", timeout: "10000",
                        data: {
                            "typeid": typeid,
                        },
                        success: function (data) {
                            if(data.message['code']!=0){
                                    var imgsrc = data.message['parkzoneslist'][0]['imgpic'];
                                    if(imgsrc==null||imgsrc==""){
                                       imginsert="<img src='http://pic.pptbz.com/pptpic/201204/2012041411433867_S.jpg' style='width: 100%;height: 150px;'>";
                                                             
                                    }else{
                                       imginsert="<img src='http://tianchao.sin-o.com/attachment/"+imgsrc+"' style='width: 100%;height: 150px;'>";
                                    }
                                   $(".img_WZ").html(imginsert);
                            }else{
                                alert("网络不稳定，请重新尝试!");
                            }
                        },error: function () {
                           alert("数据提交失败！");
                       }
                  });
    }
     
 
</script>
</body>
</html>

